﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Business.Entities;

namespace UI.Desktop
{
    public partial class MenuDesktop : Form
    {
        public MenuDesktop(Usuario UsuarioEncontrado)
        {
            InitializeComponent();
            UsuarioActual = UsuarioEncontrado;
            Decision = true;
        }

        private Usuario _UsuarioActual;
        bool _Decision;

        public Usuario UsuarioActual
        {
            get { return _UsuarioActual; }
            set { _UsuarioActual = value; }
        }

        public bool Decision
        {
            get { return _Decision; }
            set { _Decision = value; }
        }

        private void MenuDesktop_Load(object sender, EventArgs e)
        {
            MenuPrincipalDesktop menuPpal = new MenuPrincipalDesktop(UsuarioActual);
            menuPpal.MdiParent = this;
            menuPpal.Show();
        }

        private void MenuDesktop_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (Decision != false)
            {
                if (MessageBox.Show("¿Esta seguro que deasea cerrar la aplicacion?", "Salir",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Dispose();
                    Application.Exit();
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }

        private void tsmiSalir_Click(object sender, EventArgs e)
        {
            if (Decision != false)
            {
                if (MessageBox.Show("¿Esta seguro que deasea cerrar la aplicacion?", "Salir",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Dispose();
                    Application.Exit();
                }
            }
        }

        private void tsmiIniciar_Click(object sender, EventArgs e)
        {
            Decision = false;
            tsmiSalir_Click(sender, e);
            this.Dispose();
            LoginDesktop login = new LoginDesktop();
            login.Show();
        }
    }
}
